import 'package:flutter_learn_vi/src/bean/bean_user.dart';
import 'package:flutter_learn_vi/src/common/user_helper.dart';
import 'package:flutter_learn_vi/src/net/dio_utils.dart';
import 'package:flutter_learn_vi/src/utils/log_util.dart';
import 'package:get/get.dart';

import '../../../../bean/bean_user_account.dart';

class SpecialAccountDetailsController extends GetxController {
  UserSpecialAccountBean userAccountStateBean;

  Future<bool> requestUserAccount() async {
    UserBean userBean = UserHelper.getInstance.userBean;
    Map<String, dynamic> map2 = {};
    map2["mineId"] = userBean.mineId;
    int userId = userBean.userId;

    ResponseInfo responseInfo = await DioUtils.instance.getRequest(
        url: HttpHelper.userSpecialAccountUrl + "/$userId",
        queryParameters: map2);
    if (responseInfo.success) {
      //解析数据
      userAccountStateBean = UserSpecialAccountBean.fromMap(responseInfo.data);
      LogUtils.e("刷新账户信息成功");
    } else {
      userAccountStateBean = null;
    }

    update(["userSpecialAccount"]);
    return true;
  }
}
